package com.itheima.arraylist;

import java.util.ArrayList;
import java.util.Scanner;

public class FoodOpertaion {
    private ArrayList<Food> foodlist = new ArrayList<>();

    //菜品上架功能
    public void addfood() {
        Scanner sn = new Scanner(System.in);
        Food f = new Food();
        //录入菜品信息
        System.out.println("请您输入要录入的菜品名称：");
        String name = sn.next();
        f.setName(name);
        System.out.println("请您输入要录入的菜品价格：");
        double price = sn.nextDouble();
        f.setPrice(price);
        System.out.println("请您输入要录入的菜品描述：");
        String dace = sn.next();
        f.setDace(dace);
        //把菜品信息存进集合
        foodlist.add(f);
        System.out.println("上架成功");
    }

    public void showAllFoods() {
        if (foodlist.size() == 0) {
            System.out.println("什么菜品都没有，你看个球,还不去上架~");
            return;
        }
        for (int i = 0; i < foodlist.size(); i++) {
            Food f = foodlist.get(i);
            System.out.println("-----------------");
            System.out.println("菜品【" + (i + 1) + "】如下：");
            System.out.println("名称：" + f.getName());
            System.out.println("价格：" + f.getPrice());
            System.out.println("详情：" + f.getDace());
            System.out.println("-----------------");
        }
    }

    public void start() {
        Scanner sn = new Scanner(System.in);
        while (true) {
            System.out.println("-----菜品信息管理系统------");
            System.out.println("(insert)---录入菜品信息---");
            System.out.println("(all)------查看菜品信息---");
            System.out.println("(quit)-----退出系统------");
            System.out.println("------------------------");
            System.out.println("请您输入想要操作的命令：");
            String command = sn.next();
            switch (command) {
                case "insert":
                    addfood();
                    break;
                case "all":
                    showAllFoods();
                    break;
                case "quit":
                    System.out.println("已为您退出系统~");
                    return;
                default:
                    System.out.println("对不起，您输入的命令有误~");
            }
        }
    }
}
